package com.twd.websocket;


import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

/**
 * @author Chris Chan
 * Create on 2021/4/18 15:14
 * Use for:
 * Explain:
 */
public class WebSocketServerHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
        String info = ClientManager.getUsername(ctx.channel()) + " : " + msg.text();

        System.out.println(info);
        ClientManager.send(info,ctx.channel().id());
    }

}